package com.azusa.ktc_friend.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import com.azusa.ktc_friend.entity.Friend;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * @Description tb_friend 数据访问接口
 * @date 2020-10-12 18:26:41
*/
public interface FriendDao extends JpaRepository<Friend,String>,JpaSpecificationExecutor<Friend>{

    //查看是否已经关注，大于0说明有
    Integer countByUseridAndFriendid(String userid,String friendid);

    /**
     * 修改isLike的值
     * @param userId
     * @param friendId
     * @param isLike
     */
    @Query("update Friend set islike = ?3 where userid=?1 and friendid=?2")
    @Modifying
    void updateLikeByUserIdAndFriendId(String userId,String friendId,String isLike);

    /**
     * 删除关注信息
     * @param userid
     * @param friendid
     */
    @Modifying
    void deleteByUseridAndFriendid(String userid,String friendid);
}

